<?php
	require_once("../library/setup/setup.php"); 
	require_once("../library/setup/n_ini.php");
            require_once('../library/phpmailer/class.phpmailer.php');
	$setup=new setup_conf();
	$n=new n_ini();
	
?>

<?php 	$a=parse_ini_file('setup.ini',1);
	print_r($_POST );
	if($_POST != NULL){
		if(($a['config']['db_ok'] ==1) &&($a['config']['head_ok'] ==1)&&($a['config']['mail_ok'] ==1)&&($a['config']['acc_ok'] ==1)){

			$app=parse_ini_file('../application/configs/application.ini',1);


			$app['production']['resources.db.params.host'] = $a['config']['db_params_host'];
			$app['production']['resources.db.params.port'] = $a['config']['db_params_port'];
			$app['production']['resources.db.params.dbname'] = $a['config']['db_params_dbname'];
			$app['production']['resources.db.params.username'] = $a['config']['db_params_username'];
			$app['production']['resources.db.params.password'] = $a['config']['db_params_password'];

			$app['production']['mail.user'] =$a['config']['mail_user'];
			$app['production']['mail.port'] =$a['config']['mail_port'];
			$app['production']['mail.password'] =$a['config']['mail_password'];
			$app['production']['mail.host']=$a['config']['mail_host'];
			$app['production']['mail.ssl']=$a['config']['mail_ssl'];
			$app['production']['mail.from']=$a['config']['mail_from'];
			$app['production']['head.title']=	$a['config']['head_title'];
			$app['production']['head.desc']=	$a['config']['head_desc'];
			$app['production']['head.keywords']=	$a['config']['head_keywords'];
			$app['production']['head.favicon']=	$a['config']['head_favicon'];
			$app['production']['head.css']=	$a['config']['head_css'];

			$a['config']['configured']=1;
     		$n->w2i($a, "setup.ini",TRUE);
     		$n->w2i($app, "../application/configs/application.ini",TRUE);
		}

	}


?>



<?php
header('Content-Type: text/html; charset=UTF-8');
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />  
<head> 
   <title></title>
      <link href="css/setup.css" rel="stylesheet" type="text/css" />   
      <link href="css/global.css" rel="stylesheet" type="text/css" />   
      <script src="//ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js"></script>
      


</head> 
<body>

   <div class='slmenu'>
   <?php
      $home='';
      $results = Array();
      $iterator=0;
      $handler = opendir("../setup/");
      while ($file = readdir($handler)) {
         if ($file != "." && $file != ".." &&  !is_dir($file) ) {
            $tmp = (explode('.',$file));
            if($tmp[0] == 0){
               $home = $file;
            }
            $results[$tmp[0]]['file'] = $file;
            
            
            $results[$tmp[0]]['name'] = str_replace("_"," ",$tmp[1]);
            $iterator++;
         }

      }
      closedir($handler);
      asort($results);
   ?>
	

   <?php foreach($results as $row) :?>
      <a href="index.php?token=<?php echo md5($row['file']) ?>"><div class="ikon ikon_serwer"></div><?php echo $row['name'] ?> </a><br />

   <?php endforeach;?>
   
   
   </div>
   <div class='sbody'>
   <?php
   
      $token = $_GET['token']; 
      if(!empty($token)) { 
         for($i=0;$i<count($results);$i++){
            
            if(md5($results[$i]['file']) == $token){

               if(is_file("../setup/".$results[$i]['file'])){
                  include "../setup/".$results[$i]['file'];
                 //echo file_get_contents("../setup/".$results[$i]['file']);
               } 
            }
         
         }
      } else{
         include "../setup/".$results[0]['file']; 
        //echo file_get_contents("../setup/".$results[$i]['file']);
      }
   ?>
   </div>
   <div class='clear'></div>

</body>


</html> 



